type jq || pkg i jq -y
function cdk(){
echo "输入token:" && read -s token
book=`curl -s -X POST 'https://cpability.buy.139.com/cloudphone/user/bookRecord' -H 'User-Agent: okhttp/4.2.2' -H 'Content-Type: application/json; charset=UTF-8' -H 'x-channelSrc: cloudphone_app_lenovo' -H 'x-NetType: 4G' -H 'x-DeviceInfo: 4G|Android|Carry You Home|1.0.0' -H 'requestId: 2024070512181991167' -H 'appId: 12345678' -H "token: $token" -H 'sign: 2afcc5795d412028b9d2f31e221d095d' -d '{"hideStatus":true,"pageNum":1,"pageSize":100}'`
book_status=$(echo $book | jq -r '.header.status')
if [[ $book_status == "200" ]];then
phoneId=$(echo $book | jq -r '.data.phoneInstanceList[].phoneId')
if [[ $phoneId == '0' ]];then
exit
fi
for a in $phoneId;do
auth=`curl -s -X POST -H "content-type:application/json; charset=UTF-8" -H "token:$token" -d '{"phoneId":"'"$a"'","authId":"","streamType":2}' "https://cloud.139.com/ulhw/cloudphone/user/instance/auth"`
ip=$(echo $auth | jq -r '.data.resource.sdk.external.address')
port=$(echo $auth | jq -r '.data.resource.sdk.external.aport')
echo "云手机id:$a"
echo "云手机IP:$ip"
  echo -e "$ip:$((${port}))" 10000
  echo -e "$ip:$((${port} + 1))" 10001
  echo -e "$ip:$((${port} + 2))" 10002
  echo -e "$ip:$((${port} + 3))" 10003
  echo -e "$ip:$((${port} + 4))" 10004
done
elif [[ $book_status == '1024' ]];then
echo "token 无效"
else
echo "api 异常"
fi
}
cdk "${1}"